﻿using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;

namespace Perst
{
#if SILVERLIGHT
    [AttributeUsage(AttributeTargets.Field|AttributeTargets.Property)]
    public class NonSerializedAttribute : Attribute
    {
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class SerializableAttribute : Attribute
    {
    }

    public class ArrayList : List<object>
    {
        public object[] ToArray(Type elemType)
        {
            object[] arr = (object[])Array.CreateInstance(elemType, Count);
            CopyTo(arr);
            return arr;
        }

        public void AddRange(System.Collections.ICollection col)
        {
            base.AddRange((IEnumerable<object>)col);
        }
    }   

    public class Hashtable : Dictionary<object, object>
    {
        public new object this[object key]
        {
            get
            {
                object v = null;
                TryGetValue(key, out v);
                return v;
            }
            set
            {
                base[key] = value;
            }
        }

        public bool Contains(object key)
        {
            return ContainsKey(key);
        }
    }

#endif
}
